package com.zyzy.leftfourdead.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by loverforever on 2016/8/20.
 * 给HomePageFragment 填充的 适配器  首页的适配器
 */
public class HomePageFragmentAdapter extends FragmentPagerAdapter {
    //装载碎片 集合
    private List<Fragment> list=null;
    //装载标签名字的数组
    private String[]arrTitles=null;
    //构造方法 用于传值
    //这是怎么回事？
    public HomePageFragmentAdapter(FragmentManager fm, List<Fragment>list, String[]arrTitles) {
        super(fm);
        this.list=list;
        this.arrTitles=arrTitles;
    }

    @Override

    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    //获取values中的对应的标签
    public CharSequence getPageTitle(int position) {
        return arrTitles[position];
    }
}
